<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>

        function Vue(options){
            this._data = options.data
            _porxy()
            _initmethodes(this.methods)
            _createRact(this._data)
        }

        Vue.prototype={

            _createRact(data){
                if(data === null || data!='object') return

                Object.keys(data).forEach((key)=>{
                    let value = data[key]
    
                    this._createRact(value)

                    Object.defineProperty(data,key,{
                        get(){
                            return value
                        },
                        set(val){
                            value = val
                        }
                    })
                })

            },


            _initmethodes(methods){
                Object.keys(methods).forEach((key)=>{
                    this[key] = methods[key].bind(this)
                })
            },

            _porxy(){
                Object.keys(this._data).forEach((key)=>{
                    Object.defineProperty(this,key,{
                        get(){
                            return this._data[key]
                        },
                        set(value){
                            this._data[key] = value
                        }
                    })
                })
            }
        }

        const vm = new Vue({
            name:'a',
            data:{
                name:1,
                obj:{
                    num:2
                }
            }
        })
    </script>
</body>
</html>